package junior.排序;

import static util.Array.*;
import static util.Tree.*;

public class 冒泡排序 {
    public static void main(String[] args) {

        int[] array = creatArrayOneDimensional(10,50,100);
        System.out.println("原始数组：");
        showArrayOneDimensional(array);
        System.out.println("冒泡排序结果：");
        bubbleSortArray(array);
        showArrayOneDimensional(array);
    }
    public static void bubbleSortArray(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            for (int j = 0; j < array.length-1-i; j++) {
                if(array[j] > array[j+1]){
                    int temp = array[j+1];
                    array[j+1] = array[j];
                    array[j] = temp;
                }
            }
        }
    }
}
